Shortcut to Pull GitHub Repos

Tutorial
Author

Pingfan Hu

Published

March 7, 2025

This is a MacOS tutorial on how to create a shortcut to pull all your local GitHub repositories at once.

I have a lot of repositories, and I don’t want to pull them one by one. So I created a shortcut to do this. Here’s how you can do it too.

1 Shell File

The first thing you need is a shell file that pulls all your repositories. Here’s the code:

#!/bin/bash

# Text formatting
BLUE='\033[0;34m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

echo -e "${BLUE}Starting to pull all repositories...${NC}\n"

# Find all .git directories, excluding the .git directory itself if it exists
find . -type d -name ".git" ! -path "./.git" | while read -r gitdir; do
    # Get the parent directory of the .git folder (the actual repo directory)
    repo_dir=$(dirname "$gitdir")
    
    echo -e "${BLUE}Pulling${NC} ${repo_dir#./}"
    cd "$repo_dir" || continue
    git pull
    cd - > /dev/null
    echo ""
done

echo -e "${GREEN}All repositories have been updated!${NC}"

Save it as pull-all-repos.sh in the root folder of your GitHub repo. I saved it here:

Note

If you set up your GitHub desktop long time ago (before 2021), your repos are authenticated via HTTPS, which is no longer supported. A workaround is to make SSH keys, and save your SSH passphrase in the keychain (otherwise you’ll be prompted every time you pull your repo). You can follow the instructions here.

Once you are done with the SSH key setup, try to run the .sh file in the terminal to see if it works. If it does, you can proceed with the Automator and Quick Action setup.

2 Automator App

Secondly, we need an Automator application:

  1. Open Automator and select “Application” as the type of document.
  2. In the search bar on the left, type “shell”. You’ll find “Run Shell Script”.
  3. Double click on “Run Shell Script” from the actions list. It will appear on the workflow area on the right.
  4. In the shell script box, enter:
cd ~/Documents/GitHub # Change to your GitHub repo dir
./pull-all-repos.sh
  1. Save it as an application and move it into your “Application” folder. Mine has the name being “Pull All Repos”.

3 Quick Action

Thirdly, we need a Quick Action created by Automator:

  1. Open Automator and select “Quick Action” as the type of document.
  2. In the search bar on the left, type “launch”. You’ll find “Launch Application”.
  3. Double click on “Launch Application” from the actions list. It will appear on the workflow area on the right.
  4. The application will be “Contacts” by default. Change it to the “Pull All Repos” app.
  5. Save it. Mine has the name being “Pull All Repos”.

You’ll not see the saved directory, but if you wanna access it, it’s here:

/Users/<Your User Folder>/Library/Services

4 Keyboard Shortcut

The last step is to set up a keyboard shortcut to run the Quick Action:

  1. Open System Settings and scroll down to “Keyboard”.
  2. Click on “Keyboard Shortcuts…”.
  3. Select “Services” on the left, and then open the “General” dropdown menu on the right. You’ll see the “Pull All Repos” here.
  4. Click on the white space on the right and assign your preferred shortcut.

The first time you run this, you’ll be prompted:

zsh:2: permission denied: ./pull-all-repos.sh

You need to run these codes in your Terminal:

cd ~/Documents/GitHub # Change to your root dir of GitHub repo
sudo chmod +x pull-all-repos.sh

5 Trigger the Shortcut

Now, you can trigger the shortcut by pressing the keyboard shortcut you’ve set up. It will pull all your repositories at once. Once it’s done, your’ll see the Application Folder bounces in the dock (if you have it in the dock).

That’s it! You’ve created a shortcut to pull all your GitHub repositories at once. Enjoy! 🚀

Back to top